package maingoal;

import istar.agent.IstarJadeAgent;
import istar.behaviour.IstarBehaviour;
import istar.behaviour.IstarMainBehaviour;
import istar.impl.AbstractElement;
import istar.impl.AbstractMainGoal;
import jade.core.behaviours.Behaviour;
import jade.core.behaviours.OneShotBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;
import log.Log;


public class LastQuotationBeObtained extends AbstractMainGoal {
	
	private boolean log = true;
	boolean deliberateCondition = false;
	
	public LastQuotationBeObtained(IstarJadeAgent owner) {
		super("LastQuotationBeObtained", owner);
		// TODO Auto-generated constructor stub
	}

	public LastQuotationBeObtained() {
		super("LastQuotationBeObtained");
	}




	@Override
	public Behaviour getMainBehaviour() {
		return new IstarMainBehaviour(this);
	}
	
	/*
	private class WaitingRequestOrder extends IstarBehaviour{
		//Resource page = new Resource("page");
		//private AbstractMainGoal mainGoal;
		private int step = 0;
		
		public WaitingRequestOrder(AbstractMainGoal _mainGoal){
			super(_mainGoal);
			//mainGoal = _mainGoal;
		}

		@Override
		public void myAction() {
			getElement().getContent().clear();
			ACLMessage response=null;

			MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.REQUEST);
			ACLMessage msg = myAgent.receive(mt);
			if (msg!=null){
				String ticket = ((IstarJadeAgent)myAgent).getNextTicket();
				((IstarJadeAgent)myAgent).getWorkingMessages().put(ticket,msg);
				((AbstractElement)getElement()).setExecutionNumber(ticket);
				log(myAgent.getName() +" executing. Ticket="+ getElement().getExecutionNumber());
				setDeliberateCondition(true);
				String content = msg.getContent();
				getElement().getContent().add(msg);
				((IstarJadeAgent)myAgent).setKnowledgeElement(getElement().getExecutionNumber(), getElement());
				log("Agent name="+ myAgent.getName() +" received a REQUEST for page:" + content);
			}
		
			//
			//if (step==0){
			//	System.out.println(myAgent.getName()+ this.getBehaviourName() + " is executing");
			//	step=1;
			//}
			//
		}


		@Override
		public boolean done() {
			return true;
		}
		
		
	}
	*/
	
}
